<?php
class Controller {
    private $model     = '';
    private $view     = '';
    
    public function Controller(){
        $this->model    =    new Model();
        $this->view        =    new View();
    }
    
    public function doAction( $method = 'defaultMethod', $params = array() ){
        if( empty($method) ){
            $this->defaultMethod();
        }else if( method_exists($this, $method) ){
            call_user_func(array($this, $method), $params);
        }else{
            $this->nonexisting_method();
        }
    }
    
    public function link_page($name = ''){
        $links = $this->model->getLinks();
        $this->view->display($links);
        
        $result = $this->model->getResult($name);
        $this->view->display($result);
    }
    
    public function defaultMethod(){
        $this->br();
        echo "This is the default method. ";
    }
    
    public function nonexisting_method(){
        $this->br();
        echo "This is the noexisting method. ";
    }
    
    public function br(){
        echo "<br />";
    }
}

?>